<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var extent = function(){
            var value=0;
            return {
                call:function(){
                    value++;
                    console.log(value);
                }
            }
        }
        var extent = extent();
        //extent.call();//1
        //extent.call();//2
        //extent.call();//3
        
        //如果换成面向对象到写法就是
        var extent = {
            value:0,
            call:function(){
                this.value++;
                console.log(this.value);
            }
        }
        extent.call();
        extent.call();
        extent.call();
        //或者
        var Extent = function(){
            this.value=0;
        }
        Extent.prototype.call = function(){
            this.value++;
            console.log(this.value);
        }
        var extent = new Extent();

        extent.call();
        extent.call();
        extent.call();
        
    </script>
</body>
</html>